package cn.hl.feign;

import cn.hl.enums.GlobalExceptionCode;
import cn.hl.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class ProductFeignFallbackFactory implements FallbackFactory<ProductService> {
    @Override
    public ProductService create(Throwable e) {
        e.printStackTrace();
        return new ProductService() {
            @Override
            public JSONResult get(Long id) {
                return JSONResult.error(GlobalExceptionCode.SERVICE_DEMOTE_ERROR);
            }
        };
    }
}
